package cpr.command;

import cpr.DefaultCommandHandler;
import cpr.context.SolveContext;

public class CmdSolutionSolve extends DefaultCommandHandler {
	public CmdSolutionSolve() {
		super("sol-solve");
	}

	public void execute(String[] params) throws Exception {
		int wsId1 = getParameterInteger(params, 1,-1);
		int wsId2 = getParameterInteger(params, 2,-1);
		if (wsId2!=-1) {
			for (int i = wsId1; i <= wsId2; i++) {
				getCommandContext().pushCommand("$", getName()+" "+i);
			}
			return;
		}
		if (wsId1!=-1) {
			SolveContext sctx = getCommandContext().getContext().getCurrentWorksetContext().createSolveContext(wsId1);
			getCommandContext().getContext().setCurrentSolveContext(sctx);
		}
		
		SolveContext solveContext=  getCommandContext().getContext().assertCurrentSolveContext();
		solveContext.loadSolution(true);
		solveContext.solve(this);
	}
	
}

